/* $Header: /usr/cvsroot/target/h/wrn/wm/snmp/engine/v3_eng.h,v 1.3 2002/04/01 21:33:27 josh Exp $ */

/*
 * Copyright (C) 1999-2005 Wind River Systems, Inc.
 * All rights reserved.  Provided under license only.
 * Distribution or other use of this software is only
 * permitted pursuant to the terms of a license agreement
 * from Wind River Systems (and is otherwise prohibited).
 * Refer to that license agreement for terms of use.
 */


/****************************************************************************
 *  Copyright 1998 Integrated Systems, Inc.
 *  All rights reserved.
 ****************************************************************************/

/*
 * $Log: v3_eng.h,v $
 * Revision 1.3  2002/04/01 21:33:27  josh
 * make sure that engine ids conform to restricted lengths
 * (minimum of 5, maximum of 32)
 *
 * Revision 1.2  2001/11/06 21:35:06  josh
 * new revised path structure, first pass.  Also removing useless
 * shell include files.
 *
 * Revision 1.1.1.1  2001/11/05 17:47:23  tneale
 * Tornado shuffle
 *
 * Revision 9.11  2001/04/11 20:42:56  josh
 * merge from the kingfisher branch
 *
 * Revision 9.10  2001/01/19 22:22:11  paul
 * Update copyright.
 *
 * Revision 9.9  2000/07/12 18:39:30  josh
 * moving SNMP_Find_Matching_Engine_ID() to v3_eng.c -- appropriately
 * updating headers to correspond
 *
 * Revision 9.8  2000/06/09 14:54:12  josh
 * modifications due to new installation options, new proxy code
 * moved some definitions from sendntfy.h into v3_trgt.h so they'd
 * be built with the target code
 *
 * Revision 9.7.2.2  2001/03/12 22:08:00  tneale
 * Updated copyright
 *
 * Revision 9.7.2.1  2000/09/21 21:14:54  josh
 * bringing branch include files in line with root
 *
 * Revision 9.7  2000/03/17 19:48:44  meister
 * Update copyright notice
 *
 * Revision 9.6  2000/03/09 20:58:36  tneale
 * All structure definitions are now bracketted with a test that
 * potentially sets an alignment pragma.  This is to maintain compatibility
 * with the code base that had been distributed by Wind River.
 *
 * Revision 9.5  2000/03/09 17:00:01  tneale
 *  Added #ifdef for C++ to declare extern C if needed
 *
 * Revision 9.4  2000/02/04 21:54:22  josh
 * prototyping functions that may need to be called by other modules
 * this is done primarily to make the vxWorks compiler happy.
 * Warning:  the prototypes added may be duplicated by a mib_hand.h
 * file generated by Emissary.
 *
 * Revision 9.3  1999/10/29 21:47:24  josh
 * better control over how and when ENVOY_ADD_ENGINE_ADDRESS and
 * ENVOY_ADD_ENGINE_ID are defined.
 *
 * Revision 9.2  1999/10/07 23:39:56  josh
 * default definitions for ENVOY_ADD_ENGINE_ID and
 * ENVOY_ADD_ENGINE_ADDRESS
 *
 * Revision 9.1  1999/09/27 21:11:44  josh
 * fixing nits, rewriting engine id <--> address code, adding installation
 * option
 *
 * Revision 9.0  1998/10/16 22:10:24  sar
 * Update version stamp to match release
 *
 * Revision 1.6  1998/08/12 04:52:16  sar
 * revamp the initialization routines to limit the amount of
 * code that might get pulled in.
 *
 * Revision 1.5  1998/07/20 01:59:57  sar
 * Add () to SNMP_Engine_Get_My_* and ENVOY_TIME calls
 * Modify the timestamp installs so they are all the same,
 * installing ENVOY_TIME() - timestamp
 *
 * Revision 1.4  1998/07/03 16:54:53  sar
 * Remove many engine install option, moved this engine's information
 * into an engine structure
 *
 * Revision 1.3  1998/06/18 04:42:04  sar
 * Modified bflags in ebuffer to be unsigned ints and updated
 * calling routines accordingly
 *
 * Revision 1.2  1998/05/30 02:52:08  sar
 * Modifed the names used for max string length
 * Updated user lookup
 *
 * Revision 1.1  1998/05/23 19:49:40  sar
 * Include files for use with v3 code.  They define the structures
 * and entry points for the various pieces.
 * acc: access and group information
 * auth & priv: authentication and privacy
 * con: context
 * eng: engine ids, both this agents and any others it knows
 * mth: method routines, for use with mib control files
 * user: user info
 *
 */

/* [clearcase]
modification history
-------------------
01a,19apr05,job  update copyright notices
*/


#if (!defined(v3_eng_inc))
#define v3_eng_inc

#ifdef __cplusplus
extern"C" {
#endif

#if (!defined(asn1_inc))
#include <wrn/wm/snmp/engine/asn1.h>
#endif

#if (!defined(buffer_inc))
#include <wrn/wm/snmp/engine/buffer.h>
#endif

#define ETC_ENGINE_ENGINE_MIN 5
#define ETC_ENGINE_ENGINE_MAX 32

#ifdef WINDNET_STRUCT_ALIGN
#pragma align 1
#endif

typedef struct ENGINE_LEAF_S 
	{
	struct ENGINE_LEAF_S *next;
	bits8_t  *id;
	ALENGTH_T id_len;
	bits32_t  boots;
	sbits32_t offset;
	sbits32_t lasttime;
#if INSTALL_ENVOY_SNMP_V3_TARGET
	OBJ_ID_T        tdomain;        /* information to allow us to find */ 
	EBUFFER_T       taddress;       /* a remote engineid for informs   */
#endif
        } ENGINE_LEAF_T;

#ifdef WINDNET_STRUCT_ALIGN
#pragma align 0
#endif

#ifndef ENVOY_ADD_ENGINE_ADDRESS
#if (INSTALL_ENVOY_SNMP_V3_TARGET)
extern int   envoy_add_engine_address __((SNMP_PKT_T *, SNMPADDR_T *, int));

#define ENVOY_ADD_ENGINE_ADDRESS(P, A, C) \
    envoy_add_engine_address((P), (A), (C))
#elif defined(ENVOY_ADD_ENGINE_ID)
#define ENVOY_ADD_ENGINE_ADDRESS(P, A, C) (ENVOY_ADD_ENGINE_ID(P), 1)
#endif
#endif

/* global variables */
extern sbits32_t      v3_snmpEngineMaxMessageSize;
extern ENGINE_LEAF_T *v3_my_engine;
extern ENGINE_LEAF_T *root_engine;

extern int SNMP_Engine_Set_My_Info __((bits8_t *, ALENGTH_T,
				       bits32_t, sbits32_t));
#define SNMP_Engine_Get_My_ID()        (v3_my_engine ? v3_my_engine->id : 0)
#define SNMP_Engine_Get_My_ID_Length() (v3_my_engine ? v3_my_engine->id_len : 0)
#define SNMP_Engine_Get_My_Boots()     (v3_my_engine ? v3_my_engine->boots : 0)
#define SNMP_Engine_Get_My_Time()      (v3_my_engine ? \
				     (ENVOY_TIME()) - v3_my_engine->offset : 0)

#define SNMP_Engine_Get_Boots(E)     ((E)->boots)
#define SNMP_Engine_Get_Time(E)	     ((ENVOY_TIME()) - (E)->offset)
#define SNMP_Engine_Get_LastTime(E)  ((E)->lasttime)

#define SNMP_Engine_Set_Info(E, B, T) ((E)->boots = (B), \
				       (E)->offset = (ENVOY_TIME()) - (T),\
				       (E)->lasttime = (T))

extern void SNMP_Find_Matching_Engine_ID __((OBJ_ID_T *, EBUFFER_T *,
					     bits8_t **, ALENGTH_T *));
extern int             SNMP_Engine_Set_Address __((bits8_t *, ALENGTH_T,
						   OIDC_T *, int,
						   bits8_t *, ALENGTH_T));
extern ENGINE_LEAF_T * SNMP_Engine_Lookup  __((bits8_t *, ALENGTH_T));
extern int             SNMP_Engine_Install __((bits8_t *, ALENGTH_T,
					      bits32_t, sbits32_t));

extern void            get_snmpEngineID __((OIDC_T, int, OIDC_T *,
					    SNMP_PKT_T *, VB_T *));
extern void            get_snmpEngineBoots __((OIDC_T, int, OIDC_T *,
					       SNMP_PKT_T *, VB_T *));
extern void            get_snmpEngineTime __((OIDC_T, int, OIDC_T *,
					      SNMP_PKT_T *, VB_T *));

#ifdef __cplusplus
}
#endif

#endif /* (!defined(v3_eng_inc)) */


